package dryven.persistence.query;

import java.util.Calendar;

import javax.persistence.EntityManager;

import dryven.config.DatabaseConfiguration;
import dryven.persistence.provider.PersistenceProvider;
import dryven.unittest.models.ExampleModel;
import dryven.unittest.models.shop.Client;
import dryven.unittest.models.shop.Product;

public class QueryTest {
	public static void main(String[] args) {
		PersistenceProvider pp = null;
		DatabaseConfiguration cfg = null;
		EntityManager em = pp.createEntityManager(cfg);
		
		MultiQuery q = new MultiQuery(em);
		ExampleModel model = q.select(ExampleModel.class);
		model.setAge(5);
		q
			.like(model.getName(), "Bruno")
			.openAnd()
				.greaterThan(model.getExperience(), 1.0)
				.and()
				.notEqual(model.getFlags(), 0xFF)
			.close();
		
		
		for (ResultRow r : q) {
			ExampleModel m = r.result(model);
		}
		
		Query<Product> cheapProducts = new Query<Product>(em,Product.class);
		cheapProducts.littlerThan(cheapProducts.model().getPrice(), 5.0);
		for (Product p : cheapProducts) {
			
		}
	}
}
